#include <fstream>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <iterator>

using namespace std;

class Compare{
public:
	bool operator()(string a,string b) const{
		for(int i=0;i<a.length();i++)
			a[i]=tolower(a[i]);
		for(int i=0;i<b.length();i++)
			b[i]=tolower(b[i]);	
		return a<b;
	}
};

int main(int argc,char** argv){
	if(argc<2){
		cout<<"usage: command filename"<<endl;
	}
	
	typedef map<string,list<int> , Compare > strmap;
	strmap cref;
	
	ifstream file(argv[1]);
	int lineno=0;
	
	int cc;
	char c='\0';
	while(file){
		c='\0';
		while(file && !( isalpha(c) || c=='_' ) ){
			cc=0;
			file.get(c);
			if(c=='\n'){
				lineno++;
			}
			cc++;
		}
		string key;
		
		while(file && (isalnum(c) || c=='_')){
			if(c!='\0')
				key+=c;
			file.get(c);
		}
		file.putback(c);
		if(c){
			cref[key].push_back(lineno);
		}
	}
	
	strmap::const_iterator st=cref.begin();
	while(st!=cref.end()){
		cout<<(*st).first;
		cout.width(20-(*st).first.length());
		cout<<":";
		copy((*st).second.begin(),(*st).second.end(),ostream_iterator<int>(cout," "));
		cout<<"\n";
		st++;
	}
}

